<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>骨医快线</title>
    <link href="../../../css/mui.plus.css" rel="stylesheet" />
    <style>
    	.mui-input-row label {
    		width: 65%;
    	}
    	.mui-input-row label ~ input {
    		width: 35%;
    	}
    </style>
</head>
<body>
	<header class="mui-bar mui-bar-nav oe-pri-bar">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">术后1天</h1>
	</header>
	<footer class="mui-bar mui-bar-footer" style="padding: 0;height: 50px;">
        <button type="button" id="btn-commit" class="mui-btn mui-btn-primary mui-btn-block" style="padding:10px 0;">保&nbsp;&nbsp;存</button>
    </footer>
	
    <div class="mui-content oe-helper">
    	<form class="mui-input-group" id="list-input">
            <div class="mui-input-row">
                <label>白细胞(*10<sup>9</sup>)</label>
                <input type="text" name="case_post_op_1day_white_blood_cell" placeholder="请填写" style="text-align: right;">
            </div>
            <div class="mui-input-row">
                <label>血红蛋白(g/L)</label>
                <input type="text" name="case_post_op_1day_hemoglobin" placeholder="请填写" style="text-align: right;">
            </div>
            <div class="mui-input-row">
                <label>红细胞比积</label>
                <input type="text" name="case_post_op_1day_hematocrit" placeholder="请填写" style="text-align: right;">
            </div>
            <div class="mui-input-row">
                <label>白蛋白(g/L)</label>
                <input type="text" name="case_post_op_1day_albumin" placeholder="请填写" style="text-align: right;">
            </div>
            <div class="mui-input-row">
                <label>输血量(ml)</label>
                <input type="text" name="case_post_op_1day_blood_transfusion" placeholder="请填写" style="text-align: right;">
            </div>
            <div class="mui-input-row">
                <label>特殊事件</label>
                <input type="text" name="case_post_op_1day_special_note" placeholder="请填写" style="text-align: right;">
            </div>
       </form>
    </div>
	<script id="tmp-list-input" type="text/html">
		{{if data}}
			 <div class="mui-input-row">
                <label>白细胞(*10<sup>9</sup>)</label>
                <input type="text" name="case_post_op_1day_white_blood_cell" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_white_blood_cell}}">
            </div>
            <div class="mui-input-row">
                <label>血红蛋白(g/L)</label>
                <input type="text" name="case_post_op_1day_hemoglobin" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_hemoglobin}}">
            </div>
            <div class="mui-input-row">
                <label>红细胞比积</label>
                <input type="text" name="case_post_op_1day_hematocrit" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_hematocrit}}">
            </div>
            <div class="mui-input-row">
                <label>白蛋白(g/L)</label>
                <input type="text" name="case_post_op_1day_albumin" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_albumin}}">
            </div>
            <div class="mui-input-row">
                <label>输血量(ml)</label>
                <input type="text" name="case_post_op_1day_blood_transfusion" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_blood_transfusion}}">
            </div>
            <div class="mui-input-row">
                <label>特殊事件</label>
                <input type="text" name="case_post_op_1day_special_note" placeholder="请填写" style="text-align: right;" value="{{data.case_post_op_1day_special_note}}">
            </div>
		{{/if}}
	</script>
	
    <script src="../../../js/mui.min.js"></script>
    <script src="../../../js/app.js"></script>
    <script src="../../../js/lib/template.js"></script>
    <script>
    	(function($, a){
    		var wv,
    			caseId,
    			html,
    			tmpData,
    			commitData;
    			
    		$('body').on('tap', '#btn-commit', function(){
    			commitData = app.form.getJsonFromForm('list-input');
    			commitData.case_id = caseId;

				CommitDataById(commitData);
    		});
    		
    		$.plusReady(function(){
    			wv = plus.webview.currentWebview();
    			caseId = wv.caseId;
    			type = wv.type;
				
				getCaseInfoById(caseId, type);
    		});
    		
    		var getCaseInfoById = function(caseId, type){
    			app.net.get('c_old_man_hip_broke_prj_case_test/show_by_type', {case_id: caseId, case_type: type}, function(data){
    				if(data && data.code === '100') {
    					tmpData = data;
    					html = template('tmp-list-input', tmpData);
    					document.getElementById("list-input").innerHTML = html
    				}
    			});
    		}
    		
    		var CommitDataById = function(commitData){
    			app.net.post('c_old_man_hip_broke_prj_case_test/update', commitData, function(data){
    				if(data && data.code === '100') {
    					$.toast('保存成功');
    					$.back()
    				}else {
    					$.toast('您尚未进行任何修改哦');
    				}
    			});
    		}
    		
    	}(mui, app));
    </script>
</body>
</html>